layui.use(['table', 'form', 'jquery', 'common', 'laydate'], function() {
			let table = layui.table;
			let form = layui.form;
			let $ = layui.jquery;
			let common = layui.common;
			let laydate = layui.laydate;

			let cols = [
				[{
					field: "id",
					title: "ID",
					unresize: "true",
					align: "center"
				},{
					field: "pid",
					title: "PID",
					unresize: "true",
					align: "center"
				},{
					field: "type",
					title: "二维码类型",
					unresize: "true",
					align: "center"
				}, {
					field: 'beizhu',
					title: '备注',
					width: 200,
					align: 'center',
					templet:function(d){
					    return d.beizhu || '暂无备注'
					}
				}, {
					field: "money",
					title: "监控余额",
					unresize: "true",
					align: "center"
				}, {
					field: "times",
					title: "状态",
					unresize: "true",
					align: "center",
					templet: function (d){
					    return d.times;
					}
				}, {
					title: '操作',
					toolbar: '#options',
					unresize: true,
					align: 'center',
					width: 180,
				}]
			]

			table.render({
				elem: '#news',
				id: 'news',
				url: '/h/ajax/qrlistgetDataList',
				page: true,
				cols: cols,
				cellMinWidth: 100,
				skin: 'line',
				toolbar: '#toolbar',
				defaultToolbar: [{
					title: '刷新',
					layEvent: 'refresh',
					icon: 'layui-icon-refresh',
				}, 'filter', 'print', 'exports']
			});

			form.on('submit(user-query)', function(data) {
				// console.log(data.field)
				table.reload('news', {
					where: data.field,
					page:{curr: 1}
				})
				return false;
			});

			table.on('tool(news)', function(obj) {
				if (obj.event === 'remove') {
					window.remove(obj);
				}
			});

			table.on('toolbar(news)', function(obj) {
				if (obj.event === 'refresh') {
					window.refresh();
				}
			});

			// 数据删除
			window.remove = function(obj) {
				layer.confirm('确定要删除该数据', {
					icon: 3,
					title: '提示'
				}, function(index) {
					layer.close(index);
					let loading = layer.load();
					$.ajax({
						url: '/h/ajax/qrlistdelete',
						data: {
							id: obj.data['id']
						},
						dataType: 'json',
						type: 'POST',
						success: function(res) {
							layer.close(loading);
							//判断有没有权限
							if (res.code == 200) {
								layer.msg(res.msg, {
									icon: 1,
									time: 1000
								}, function() {
									obj.del();
								});
							} else {
								layer.msg(res.msg, {
									icon: 2,
									time: 1000
								});
							}
						},
						error:function(){
						    layer.close(loading);
						    layer.msg("服务器错误!", {
								icon: 2,
								time: 1000
							});
						}
					})
				});
			}

			window.refresh = function(param) {
				table.reload('news');
			}
		})